package com.waves.biz;

import org.springframework.stereotype.Repository;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @Description: 用户仓储类
 **/
@Repository
public class UserRepository {
    private final ConcurrentMap<Integer, User> userDB = new ConcurrentHashMap<>();

    public User saveDB(User user) {
        userDB.put(user.getId(), user);
        return user;
    }

    public User getFromDB(Integer id) {
        return userDB.get(id);
    }

    public void removeFromDB(Integer id) {
        userDB.remove(id);
    }
}
